home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
batch
/
batprogs
/
batprogs.doc
next >
Wrap
Text File
|
1987-06-23
|
7KB
|
226 lines
Batch File Utilities
Copyright Psuedonym Software 1984
Written by T. P. Devitt
Introduction:
-------------
With the advent of the IBM PC, home computerists were given access to a
facility that had previously been reserved for mainframe computers. On large
IBM computers that facility is known as IBM Job Control Language, or JCL for
short. On the PC, that concept was implemented in the form of the PC Dos Batch
commands. As powerful as these batch commands may be, they do lack two very
important features:
1) The ability to accept operator input and
2) The ability to perform branching within the batch file,
based on operator input
Of course, true variables would be nice........
The utilities included in this package help to provide some of these missing
features.
Limited license:
----------------
With a very few exceptions, you are free to use, copy and share these programs
with others, provided the following conditions are met:
1. The programs included in this package must be distributed
as a complete package, together with this documentation,
in unmodified form. The programs included in this package
are: Beep.com, Choose.com, Input.com, Inputb.com, Read.com,
Turn.com and this file, batprogs.doc.
2. No fee may be charged for this package, except for the
reasonable value of the diskette on which it is provided,
without the prior written consent of Psuedonym Software.
Commercial interruption:
------------------------
This package is distributed as user-supported software. If you find
these programs useful, a donation ($10 suggested) is requested. Those
who send a donation will be placed on a mailing list and will be
informed of all future revisions. In addition, registered users may
obtain support by either writing Psuedonym Software, or by contacting
our bulletin board at 818-441-1904.
Disclaimer:
-----------
The programs in this package are distributed on an "as is" basis. Neither
Psuedonym Software, or any of its employees, assume any responsiblity for loss
or damages, either real or imagined, arrising from the use of of these
programs, or the lack thereof.
While every effort has been made to ensure that these programs contain no bugs,
and to correct any that may be discovered, we expressly deny any legal
responsibility to do so.
Input.com:
----------
Input.com allows a batch file to accept a yes or no answer from the operator.
The prompt string is entered as a parameter of the input command, to which '
(Y/N)' is automatically appended.
A response of 'Y' or 'y' returns an error code of 0. Any other response
returns an error code of 1.
Branching within a batch file can be accomplished by checking the error return
code through the ERRORLEVEL batch sub-command. (See the IBM Dos manual for a
complete discussion of the ERRORLEVEL command.)
Syntax: INPUT <your prompt goes here>
Example: INPUT Do you wish to backup your files now ?
Result: Do you wish to backup your files now ? (Y/N) _
Input.com batch file example:
ECHO OFF
CLS
INPUT Do you want to go to work today ?
IF ERRORLEVEL 1 GOTO NOWORK
....work.... | Optional code
....work.... |
GOTO END
:NOWORK
....play.... | Optional code
....play.... |
:END
CLS
ECHO TH-TH-THAT'S ALL, FOLKS !!!!
Inputb.com:
-----------
Inputb.com is identical to Input.com, except that the console beeps when when
the prompt message is printed.
Choose.com:
-----------
Choose.com is a generalized version of Input.com. It allows you to operator to
choose an item from a menu of choices. operator to choose an item from a menu
of choices.
Syntax: CHOOSE <your text string prompt goes here>
Example: CHOOSE Select an item (1 - 8) :
Programming considerations:
Menu choices may be alphabetical or numerical, but should start with either 'A'
or '1' for best results. Choose will return an error code which is the index
of the menu item selected. For example, menu item A or 1 will return error
code 1, B or 2 will return 2, etc. The error return code can be examined from
within a batch file by using the PC DOS BATCH command 'ERRORLEVEL'. Based on
the results of ERRORLEVEL, you can control branching to various sections of
your batch file.
Constraints:
If you use a numerical menu, you are limited to 9 menu choices ( 1 - 9). An
alpha menu theoretically allows you 32 choices, but after 'Z' things might tend
to get a little confusing. Lowercase letters are converted to uppercase, so
'A' and 'a' will produce the same result.
Batch file example:
ECHO OFF
CLS
READ README.DAT (See READ command, following)
CHOOSE ENTER YOUR CHOICE (A - H):
CLS
IF ERRORLEVEL 8 GOTO END
IF ERRORLEVEL 7 READ TURN.DOC
IF ERRORLEVEL 6 READ READ.DOC
IF ERRORLEVEL 5 READ PLEASE.DOC
IF ERRORLEVEL 4 READ INPUTB.DOC
IF ERRORLEVEL 3 READ INPUT.DOC
IF ERRORLEVEL 2 READ CHOOSE.DOC
IF ERRORLEVEL 1 READ BEEP.DOC
PAUSE
%0 (causes re-execution of batch file)
:END
CLS
You may have noticed that the ERRORLEVEL is checked on a greater to lesser
basis. This is because the ERRORLEVEL command performs its compare on a
equal-to-or-greater-than basis.
Turn.com:
---------
Turn.com turns on or off either caps lock or num lock from within a
batch file.
Syntax: TURN caps/num on/off
Example: Turn caps off num on
Turn num on
Turn num on caps on
Constraints:
Only the toggle key you specifically reference will be turned on. For example,
TURN CAPS ON will result in caps lock being turned on and num lock being turned
off. TURN CAPS ON is therefore equivalent to TURN CAPS ON NUM OFF. If you
want a specific key turned on, you MUST specify that key as being ON. If you
do not, it will be turned off.
This program does not affect either the SCROLL LOCK or INSERT key.
Beep.com:
---------
Beep.com may be inserted into any batch file to produce a tone which will
signal the operator that some event has occurred. For instance, you might want
to inform the operator that a backup procedure has finished its execution.
Syntax: Beep
Read.com:
---------
Read.com outputs the contents of a text file to the console one screen at a
time. It is designed to work best with the output of text processors, such as
EDLIN of SPFPC. Each screen line should be terminated by a carriage return and
a line feed. Read.com will work with the output from most wordprocessors, but
because many of them do not use the above convention, screen formatting may be
unusual.
Read.com fully supports path (subdirectory) names. If the file you wish to
read is on the default drive, the drive specifier is optional.
Syntax: READ [d:][\path\]filename.ext
Examples: READ readme.doc
READ c:\mydir\myfile.doc
READ \yourdir\yourfile.doc
Psuedonym Software
161 S. Sunnyslope Ave.
Pasadena, Ca. 91107